install.packages("texreg")
library(texreg)


#setwd("~/Dropbox/Job Market Paper/IO Revisions/Replication_Files/Replication_Appendix/A_Fig_11")


thedata<-read.csv(file="contemp_wheat.csv")


thedata$dup<-ifelse(duplicated(thedata)==T,1,0)

thedata<-subset(thedata,thedata$dup==0)



temp<-tapply(thedata$MEAN,thedata$countries,mean)

agr_sut<-tapply(thedata$agr_sut,thedata$countries,unique)

wheat<-tapply(thedata$Wheat,thedata$countries,mean)



pdf(file="Figure_A11.pdf")
plot(temp,agr_sut,cex=wheat/10000,pch=16,type="n",col="dark blue",xlab="Avg Temp 1960-2000",ylab="Suitability for Wheat")

grid()

points(temp,agr_sut,cex=wheat/10000,pch=16,type="p",col="dark blue")


dev.off()


data1<-data.frame(temp,agr_sut,names(temp))

names(data1)<-c("temp","agr_sut","names")

data2<-data.frame(wheat,names(wheat))

names(data2)<-c("wheat","names")


data3<-merge(data1,data2,by="names",all=T)


ft1<-lm(agr_sut~abs(temp-10.5),data=data3)

ft2<-lm(wheat~abs(temp-10.5),data=data3)



print(texreg(list(ft1,ft2)))

